//https://leetcode.cn/problems/single-number-ii/

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int x = 0;
        for (int i = 0; i < 32; i++)
        {
            //统计每一位的和
            int sum = 0;
            for (auto e : nums)
            {
                if ((e >> i) & 1 == 1)
                    sum++;
            }
            //判断每一位的和模上3是否为1
            if (sum % 3 == 1)
                //修正x第i位 0为1
                x |= (1 << i);

        }

        return x;
    }
};